my_str = "itheima and itcast"
value = my_str[2]
value2 = my_str[-16]
print(value, value2)  # h h
# 字符串不可以修改
value_i = my_str.index("and")
print(value_i)

# 字符串.replace(字符串1，字符串2)
new_my_str = my_str.replace('it','程序')
print(new_my_str)

# 分割字符串 split('字符串')
path = 'home/walle/str/stu'
ret = path.split('/')
print(ret)  # ['home', 'walle', 'str', 'stu']

# strip方法
# 不传入参数则就是去除前后空格，传入就是去除前后指定字符串
# my_str = "  itheima and itcast  "
# print(my_str)
# print(my_str.strip())
#
# my_str = "12  itheima and itcast  21"
# print(my_str.strip('12'))
#
# # count
# count = my_str.count('i')
# print(count)
#
# num = len(my_str)
# print(num)

# 案例
str = 'itheima itcast boxuegu'
count = str.count('it')
new_str = str.replace(' ', '|')
new_str2 = new_str.split('|')
print(count, new_str, new_str2)